package com.sale.system.controller;

import com.sale.common.core.web.controller.BaseController;
import com.sale.system.api.domain.SysAuxiliaryUnitDetail;
import com.sale.system.api.model.MaterialUnitDto;
import com.sale.system.service.ISysAuxiliaryUnitDetailService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * 多单位控制层
 */
@RestController
@RequestMapping("/sys-auxiliary-unit-detail")
public class SysAuxiliaryUnitDetailController extends BaseController {

    @Resource
    ISysAuxiliaryUnitDetailService sysAuxiliaryUnitDetailService;

    /**
     * 根据物料编码查询出单位信息和辅助单位(返回map)
     */
    @GetMapping("/getUnitByCodeToMap")
    public Map<String, MaterialUnitDto> getUnitByCodeToMap(){
        return sysAuxiliaryUnitDetailService.getUnitByCodeToMap();
    }

    /**
     * 获取多单位列表(单位转换使用)
     */
    @GetMapping("/getUnitByMaterialId")
    public List<SysAuxiliaryUnitDetail> getUnitByMaterialId(Long materialId){
        return sysAuxiliaryUnitDetailService.getUnitByMaterialId(materialId);
    }
}
